home *** CD-ROM | disk | FTP | other *** search
- /*
- dashing text.c
-
- This file demonstrates dashing of text along a curve.
-
- NOTES:
- • This file requires the following files to run correctly:
- "graphics shell.c", "ColorLibrary.c", "FontLibrary.c",
- "GraphicsDebugLibrary.c", "TransformLibrary.c".
-
- • This file prints the "best" in landscape mode.
-
-
- Change History:
-
- 4/96 bob Updated #includes to support changed GX Library names.
- Updated the note regarding the files needed to run, and copyright date.
-
- ©1990 -1996 Apple Computer, Inc.
- All rights reserved.
- */
-
-
- #include <events.h>
- #include <windows.h>
-
- #include "FontLibrary.h"
- #include "GraphicsLibraries.h"
- #include <GXEnvironment.h>
- #include "graphics shell.h"
-
- //
- // Set up the title and size of the window
- //
- Str255 gWindowTitle = "\p Dashing text";
- Rect gWindowQDRect = {50, 50, 240, 495};
-
- //
- // gGraphicsHeapSize sets the size of the graphics heap created by calling the GXNewGraphicsClient routine
- // in main () within graphics shell.c. You can determine the amount of graphics heap required by using GraphicsBug.
- // With gGraphicsHeapSize set to 105k, I had 3 free blocks left in the graphics heap. Sounds good to me.
- //
- long gGraphicsHeapSize = 105;
-
- gxShape gDashingShape;
-
-
- /*------ DoInitialization ---------------------------------------------------------------------------------*/
-
- void DoInitialization(aWindow)
- WindowPtr aWindow;
- {
- gxCurve curvepts = {{ff(10),ff(100)},{ff(150), -ff(55)},{ff(410),ff(150)}};
- gxDashRecord textDash;
-
- InitCommonColors();
-
- //
- // Create the text shape that will be dashed
- //
- textDash.dash = GXNewText(22,(unsigned char*)"QuickDraw™ GX is here!", nil);
- SetShapeCommonFont(textDash.dash, timesFont);
- GXSetShapeTextSize(textDash.dash, ff(35));
-
- //
- // Set up the dash record. Things to note:
- // • scale should equal the text size. This will make sure that the text is dashed to the size of the curve
- // • If you want the textDash to be only used once on the curve, the advance must be larger than the curve's
- // length. You could use GXGetShapeLength (gDashingShape, ...); to determine the length of the curve and use this
- // value for advance.
- //
- textDash.attributes = gxBreakDash | gxAutoAdvanceDash;
- textDash.advance = ff(330);
- textDash.phase = 0;
- textDash.scale = ff(35);
-
- GXSetShapeType(textDash.dash, gxPathType);
-
- //
- // Create the gxCurve to be dashed to.
- //
- gDashingShape = GXNewCurve(&curvepts);
- GXSetShapePen(gDashingShape, ff(35));
- SetShapeCommonColor (gDashingShape, blue);
-
- //
- // Add the textDash to the style of the gDashingShape. Since, we are adjusting the gxStyle of our shape and
- // this shape currently references the "default" style, GX graphics will make a copy of the style
- // and attach it to our shape.
- //
- GXMoveShapeTo (gDashingShape, ff(30), ff(130));
- GXSetShapeDash (gDashingShape, &textDash);
- GXDisposeShape(textDash.dash);
- }
-
-
- /*------ DoDraw ---------------------------------------------------------------------------------------*/
-
- void DoDraw(aWindow)
- WindowPtr aWindow;
- {
- GXDrawShape (gDashingShape);
- }
-
-
- /*------ DoDispose -------------------------------------------------------------------------------------*/
-
- void DoDispose(aWindow)
- WindowPtr aWindow;
- {
- //
- // You should always dispose of your GX graphics objects before tossing your window. Why? It's generally good
- // form and this approach guarantees that everything is disposed. If you had not disposed of everything, the
- // call to DisposeWindow should dispose of the objects. If you are running the debugging version of the
- // SecretGraphics init with notices set, you will receive a notice that you had not disposed of everything. You
- // can turn notices on in this file by setting gDebugging = TRUE (above).
- //
- GXDisposeShape(gDashingShape);
- GXDisposeShape(gWindowBoundsShape);
- DisposeCommonColors();
- DisposeWindow(aWindow);
- }
-
-
-
- /*------ DoClick ---------------------------------------------------------------------------------------*/
-
- void DoClick( orgMouseLoc, theWindow )
- gxPoint orgMouseLoc;
- WindowPtr theWindow;
- {
- }
-
-
- /*------ DoIdle ----------------------------------------------------------------------------------------*/
-
- void DoIdle(aWindow)
- WindowPtr aWindow;
- {
- }
-